﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataProvider;
using DataAccess;
using DomainModel;

namespace BussinessLogic
{
    public class ProductManager
    {
        private readonly IProductProvider Provider = new ProductAccess();

        public void CreateNewCategory(Category category)
        {
            Provider.CreateCategory(category);
        }

        public IEnumerable<Category> GetAllCategories()
        {
            return Provider.GetAllCategories();
        }

        public IEnumerable<Category> GetChildrenCategoriesByParentID(int parentId)
        {
            return Provider.GetChildrenCategoriesByParentID(parentId);
        }

        public Category GetCategoryByID(int id)
        {
            return Provider.GetCategoryByID(id);
        }

        public void DeleteCategoryByID(int id)
        {
            Provider.DeleteCategoryByID(id);
        }

        public void UpdateCategory(Category category)
        {
            Provider.UpdateCategory(category);
        }

        public void CreateProduct(Product product)
        {
            Provider.CreateProduct(product);
        }

        public IEnumerable<Product> GetAllProducts()
        {
            return Provider.GetAllProducts();
        }

        public void DeleteProductByID(int id)
        {
            Provider.DeleteProductByID(id);
        }

        public void UpdateProduct(Product product)
        {
            Provider.UpdateProduct(product);
        }

        public Product GetProductByID(int id)
        {
            return Provider.GetProductByID(id);
        }

        public void EditProduct(Product product)
        {
            if (product.ID == 0)
            {
                product.ID = null;
                CreateProduct(product);
            }
            else
            {
                UpdateProduct(product);
            }
        }


        public IEnumerable<Order> GetAllOrders()
        {
            return Provider.GetAllOrders();
        }

        public void DeleteOrderByID(int id)
        {
            Provider.DeleteOrderByID(id);
        }

        public Order GetOrderByID(int id)
        {
            return Provider.GetOrderByID(id);
        }

        public IEnumerable<OrderDetail> GetOrderDetailsByOrderID(int id)
        {
            return Provider.GetOrderDetailsByOrderID(id);
        }
    }
}
